package com.test.test.service.impl;

import java.util.Date;

import javax.transaction.Transactional;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.test.test.dao.RoleRepos;
import com.test.test.dto.common.PageResp;
import com.test.test.dto.common.ResultResp;
import com.test.test.dto.userModule.RolePamar;
import com.test.test.dto.userModule.RoleResp;
import com.test.test.entity.Role;
import com.test.test.service.RoleService;
import com.test.test.utils.ResultRespUtil;

@Service
@Transactional(rollbackOn = Exception.class)
public class RoleServiceImpl implements RoleService {

	@Autowired
	RoleRepos roleRepos;

	@Override
	public ResultResp<Integer> addRole(RolePamar pamar) throws Exception {
		// TODO Auto-generated method stub
		ResultResp<Integer> resp = new ResultResp<>();
		Role role = new Role();
		BeanUtils.copyProperties(pamar, role);
		Date createTime = new Date();
		role.setCreateTime(createTime);
		role.setModifyTime(createTime);
		roleRepos.save(role);
		resp.setData(role.getRoleId());
		ResultRespUtil.successCode(resp);
		return resp;
	}

	@Override
	public ResultResp<Boolean> modifyRole(RolePamar pamar) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ResultResp<RoleResp> findByRole(Integer roleId) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ResultResp<PageResp<RoleResp>> pageRole(RolePamar pamar) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ResultResp<RoleResp> deleteByRoleId(Integer roleId) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

}
